<?php

require_once __DIR__ . '/../../config.php';

/**
 * \BF\Config\Value test case.
 *
 * @since v1.0.0
 */
class XmlReaderTest extends \PHPUnit_Framework_TestCase
{

   # <editor-fold defaultstate="collapsed" desc=" - - -   P R I V A T E   F I E L D S   - - - - - - - - - - - - - - - - - - - - - -">

   private $config;
   /**
    * @var \BF\Config\Reader\Xml
    */
   private $reader;

   # </editor-fold>

   public function setUp()
   {

      $this->config = array();
      $this->reader = new \BF\Config\Reader\Xml( __DIR__ . '/test.xml' );

   }

   public function testCanRead()
   {
      $this->assertTrue  ( $this->reader->canRead(), "Test ->canRead() fails" );
   }

   public function testIsOpen()
   {
      $this->assertTrue  ( $this->reader->isOpen(), "Test ->isOpen() fails" );
   }

   public function testAll()
   {
      $this->reader->reset();
      $all = $this->reader->readAll();
      $this->assertEquals( 3, count( $all ) , "Test count() fails" );
      $this->assertTrue( isset( $all[ 'ConfValue1' ] ), "Test isset('ConfValue1') fails" );
      $this->assertTrue( isset( $all[ 'ConfValue2' ] ), "Test isset('ConfValue2') fails" );
      $this->assertTrue( isset( $all[ 'ConfValue3' ] ), "Test isset('ConfValue3') fails" );
      $this->assertSame( true, $all->getValue( 'ConfValue1' )->value, "Test get('ConfValue1') fails" );
      $this->assertSame( 1001, $all->getValue( 'ConfValue2' )->value, "Test get('ConfValue2') fails" );
      $this->assertSame( "I'am a string! :-)", $all->getValue( 'ConfValue3' )->value, "Test get('ConfValue3') fails" );
   }

}

